/*

Author   : chaos

FileName : class_con.cpp

Date     : 13/08/17 13:32:23

*/
#include <iostream>
using namespace std;

class centimeter
{
    private:
        float cm;
        static char unit[3];
        friend class meter;

    public:
        centimeter(float cm):cm(cm){}
        void show_data(){cout << cm << unit <<  endl;}
};

char centimeter::unit[3] = "cm";

class meter
{
    private:
        float m;
        static char unit[2];

    public:
        meter(float m):m(m){}
        meter(centimeter cm):m(cm.cm /100){}
        operator centimeter(){
            cout << "call operator centimeter!" << endl;
            return centimeter(m*100);
        }
        void show_data(){cout << m << unit << endl ;}
};

char meter::unit[2] = "m";

int main(int argc ,char *argv[])
{

    meter my_meter(1.25);
    centimeter my_cm(0);

    my_cm = my_meter;

    my_cm.show_data();

    meter my_meter_1(my_cm);

    my_meter_1.show_data();

    return 0;
}
